// JavaScript Document

$(function(){
	p = $("#narrow_down").position();
	if(p.top < 630){
		$("#narrow_down").css('position','fixed');	
	}
	$(window).scroll(function(){
		var lastScroll = $(document).scrollTop();
		if(lastScroll >= 50){
			$("#header_nav").removeClass("cls-opacity");
		}else{
			$("#header_nav").addClass("cls-opacity");
		}
		var p = $("#narrow_down").position();
		if(lastScroll >= 1){
			$("#narrow_down").css('position','absolute');
		}else{
			if(p.top < 630){
				$("#narrow_down").css('position','fixed');
			}
		}
	});
	
	$('#back-top').click(function () {
		$('body,html').animate({
			scrollTop: 0
		}, 800);
		return false;
	});
	
	$("#narrow_down").click(function(){
		$('body,html').animate({
			scrollTop: 520
		}, 1000,'easeInOutCubic');
		return false;
	});
	
	$(window).resize(function(){
		$('#content_holder').height($(window).height() - 195);
	});
	$('#content_holder').height($(window).height() - 195);
	
	/* Content scroll */
	"use strict";
	/*$('#content_holder').perfectScrollbar({wheelSpeed:100});*/
	$('.carousel').carousel({
		pause:false,
		interval:8000
	});
	
	$('#birthday, #on_date').datepicker({
		viewMode: 2	
	});
	$("#start_time, #to_time").timepicker();
	
	$('#register_form').bind('click', function (e) { e.stopPropagation() });
	$('#signin_form').bind('click', function (e) { e.stopPropagation() });
	
	var h = 0;
	$("#advance_search_bt").click(function(){
		$("#advance_search").toggle(300);
		
		if(h == 0){
			h = 1;
			$("#search_box").addClass('search-toggle');
			$("#advance_search_icon").removeClass('icon-chevron-down');
			$("#advance_search_icon").addClass('icon-chevron-up');
		}else{
			h = 0;
			$("#search_box").removeClass('search-toggle');
			$("#advance_search_icon").removeClass('icon-chevron-up');
			$("#advance_search_icon").addClass('icon-chevron-down');
		}
	});
	
})
